﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.Interface;
using OpenAuth.App.JY;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;

namespace OpenAuth.Mvc.Controllers.JY
{
    public class PLA_PROJECT_ALLController : BaseController
    {

        private PLA_PROJECT_ALLApp _app;
        
        public PLA_PROJECT_ALLController(IAuth auth, PLA_PROJECT_ALLApp app) : base(auth)
        {
            _app = app;
        }
        //[AllowAnonymous]
        public IActionResult Index() {
            {
                return View();
            }
        }
        public async Task<string> Load(PLA_PROJECT_ALLListReq request) {
            var data = new TableData();
             data = await _app.Load(request);
            return JsonHelper.Instance.Serialize(data);
        }
        [HttpPost]
        public string Add(PLA_PROJECT_ALL obj) {
            try
            {
                _app.Add(obj);
            }
            catch (Exception ex)
            {

                Result.Code = 500;
                Result.Message = ex.Message;
            }
            return JsonHelper.Instance.Serialize(Result);

        }
        public string Upp(PLA_PROJECT_ALL obj) {
            try
            {
                _app.Upp(obj);
            }
            catch (Exception ex)
            {

                Result.Code = 500;
                Result.Message = ex.ToString();
            }
            return JsonHelper.Instance.Serialize(Result);
        }
    }
}
